#ifndef SGU_ZMEMORY_H
#define SGU_ZMEMORY_H

SGU_NS_BEGIN


class ConstSegment : public UsedObj
{
	public:
	ConstSegment() {}
	virtual ~ConstSegment() {}

	virtual size_t size() const = 0;
	virtual const char * cptr() const = 0;
};

class Segment : public ConstSegment
{
	public:
	Segment() {}
	virtual ~Segment() {}

	virtual char * ptr() const = 0;
};

class DynamicSegment : public Segment
{
	public:
	DynamicSegment() {}
	virtual ~DynamicSegment() {}
	
	virtual void resize(size_t) = 0;
	virtual void clear(size_t) = 0;
	virtual void clear() = 0;
};

class Memory : public DynamicSegment, public Serializable
{
	public:

	Memory();
	Memory(size_t);
	virtual ~Memory();
	Memory(const ConstSegment &);
	Memory & operator = (const ConstSegment &);

	virtual size_t size() const;
	virtual const char * cptr() const;
	virtual char * ptr() const;
	
	virtual void resize(size_t);
	virtual void clear(size_t);
	virtual void clear();

	void serialize(BOStorage &) const;
	void serialize(BIStorage &);
	void serialize(TOStorage &) const;
	void serialize(TIStorage &);


	private:
	static const size_t _s_minsize = 12;
	void * _ptr;
	size_t _size;
	size_t _allocsize;
};



SGU_NS_END

#endif
